﻿using System;
using System.Collections.Generic;

namespace Web.Auction.Bid.Models
{
    public class Auction
    {
        public int Id { get; set; }
        /// <summary>
        /// 产品Id
        /// </summary>
        public int ProductId { get; set; }
        /// <summary>
        /// 商品Id
        /// </summary>
        public string ProductVariantId { get; set; }
        /// <summary>
        /// 拍品等级
        /// </summary>
        public AuctionGrade Grade { get; set; }
        /// <summary>
        /// 每次出价消耗金额
        /// </summary>
        public int PerPrice { get; set; }

        /// <summary>
        /// 重置秒数
        /// </summary>
        public int Interval { get; set; }
        /// <summary>
        /// 拍品名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 图片
        /// </summary>
        public string PictureSrc { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 成本价格
        /// </summary>
        public decimal Cost { get; set; }
        /// <summary>
        /// 购买价格
        /// </summary>
        public decimal BuyPrice { get; set; }
        /// <summary>
        /// 参考价格
        /// </summary>
        public decimal MarketPrice { get; set; }
        /// <summary>
        /// 安全价格
        /// </summary>
        public decimal SafePrice { get; set; }
        /// <summary>
        /// 兑换积分(0为不可兑换积分)
        /// </summary>
        public int IntegralExchange { get; set; }
        /// <summary>
        /// 是否可补差购买
        /// </summary>
        public bool DiffBuySupported { get; set; }
        /// <summary>
        /// 可以补差购买数量的条件
        /// </summary>
        public DiffBuyLimitation DiffBuyLimitation { get; set; }
        /// <summary>
        /// 补差购买数量的条件的值
        /// </summary>
        public int DiffBuyLimitationValue { get; set; }
        /// <summary>
        /// 是否支付0元竞拍
        /// </summary>
        public bool ZeroSupported { get; set; }
        /// <summary>
        /// 是否可以使用免费拍币
        /// </summary>
        public bool FreeBidSupported { get; set; }
        /// <summary>
        /// 可以使用免费拍币的条件
        /// </summary>
        public FreeBidLimitation FreeBidLimitation { get; set; }
        /// <summary>
        /// 可以使用免费拍币的条件的值
        /// </summary>
        public int FreeBidLimitationValue { get; set; }
        /// <summary>
        /// 附加费
        /// </summary>
        public decimal AdditionalCharge { get; set; }
        /// <summary>
        /// 上架时间
        /// </summary>
        public DateTime OnlineTime { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public string StartTime { get; set; }
        /// <summary>
        /// 开始日期时间
        /// </summary>
        public DateTime StartDateTime { get { return DateTime.Parse(StartTime); } }
        /// <summary>
        /// 结束时间
        /// </summary>
        public string StopTime { get; set; }
        /// <summary>
        /// 结束日期时间
        /// </summary>
        public DateTime StopDateTime { get { return DateTime.Parse(StopTime); } }
        /// <summary>
        /// 当前价格
        /// </summary>
        public decimal BidPrice { get; set; }
        /// <summary>
        /// 当前出价用户Id
        /// </summary>
        public int UserId { get; set; }
        /// <summary>
        /// 当前用户昵称
        /// </summary>
        public string NickName { get; set; }
        /// <summary>
        /// 当前用户
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 预期成交时间
        /// </summary>
        public DateTime? ExpectedTime { get; set; }
        /// <summary>
        /// 实际成交时间
        /// </summary>
        public DateTime? TransactionTime { get; set; }
        /// <summary>
        /// IpAddress
        /// </summary>
        public string IpAddress { get; set; }
        /// <summary>
        /// 订单Id
        /// </summary>
        public string OrderId { get; set; }
        /// <summary>
        /// 扩展信息
        /// </summary>
        public string Extra { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public AuctionStatus Status { get; set; }

        /// <summary>
        /// 创建者
        /// </summary>
        public string CreatedBy { get; set; }

        /// <summary>
        /// 创建日期时间
        /// </summary>
        public DateTime CreatedOn { get; set; }

        public int Counter { get; set; }

        /// <summary>
        /// 免费出价次数
        /// </summary>
        public int FreeBidCount { get; set; }
        /// <summary>
        /// 每个用户免费出价次数
        /// </summary>
        public IDictionary<int, int> FreeBidUsers { get; set; }
    }

    public enum AuctionGrade : byte
    {
        Normal = 0,
        Gift = 1,
        Silver = 2,
        Gold = 3,
        Platinum = 4,
        Diamond = 5
    }

    public enum DiffBuyLimitation : byte
    {
        /// <summary>
        /// 无限制
        /// </summary>
        Unlimited = 0,
        /// <summary>
        /// 只能N次
        /// </summary>
        NTimesOnly = 1,
        /// <summary>
        /// 每个用户只能N次
        /// </summary>
        NTimesPerCustomer = 2,
    }

    public enum FreeBidLimitation : byte
    {
        /// <summary>
        /// 无限制
        /// </summary>
        Unlimited = 0,
        /// <summary>
        /// 只能N次
        /// </summary>
        NTimesOnly = 1,
        /// <summary>
        /// 每个用户只能N次
        /// </summary>
        NTimesPerCustomer = 2,
    }

    public enum AuctionStatus : byte
    {
        Normal = 0,
        Finished = 1,
        Suspended = 2,
        Deleted = 3
    }

    public enum MarketState
    {
        Open,
        Closed
    }
}